package role

import (
	"context"
	"go-zero-project/services/user/rpc/pb"

	"go-zero-project/services/user/api/internal/svc"
	"go-zero-project/services/user/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteRoleLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRoleLogic {
	return &DeleteRoleLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteRoleLogic) DeleteRole(req *types.DeleteRoleReq) error {
	// 1.builder rpc request
	roleReq := pb.DeleteRoleReq{RoleIdArr: req.RoleIdArr}
	// 2.request rpc
	_, err := l.svcCtx.UserCenterClient.DeleteRole(l.ctx, &roleReq)
	if err != nil {
		return err
	}
	/// 3.return obj
	return nil
}
